﻿using System;


namespace SZJT.Framework.Adapter
{
    internal static class WebServiceHelper
    {
        /// <summary> 
        /// 动态调用WebService 
        /// </summary> 
        /// <param name="url">WebService地址</param> 
        /// <param name="methodname">方法名(模块名)</param> 
        /// <param name="args">参数列表</param> 
        /// <returns>object</returns> 
        internal static object CallbackWebService(string url,string methodname, object[] args)
        {
            try
            {
                return new WSHelper().InvokeWebService(url, methodname, args);
            }
            catch
            {
                LoggerHelper.WriteStackTraceInfo("动态调用WebService时发生错误");
                return "";
            }
        }

        /// <summary>
        /// 动态创建WebService实例，同时输出实例Type类型
        /// </summary>
        /// <param name="url"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        internal static object CallbackWebService(string url,out Type type)
        {
            try
            {
                return new WSHelper().CreateInstance(url, out type);
            }
            catch
            {
                type = null;
                LoggerHelper.WriteStackTraceInfo("创建适配器实例时发生错误，创建实例失败");
                return null;
                //执行错误信息写入操作
            }
        }
    } 
}
